<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../plugins/elementui/index.css">
    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min(1).css">
    <link rel="stylesheet" href="../css/style.css">
</head>
<body>
原密码<input type="text" id="0" v-model="password1"><br/>
新密码<input type="password" id="1" v-model="password2"><br/>
确定密码<input type="password" id="2" v-model="password3"><br/>
<button type="submit" @click="update()">提交</button>
<button type="submit" onclick="history.back(-1);">返回</button>
</body>
<!-- 引入组件库 -->
<script src="../js/vue.js"></script>
<script src="../plugins/elementui/index.js"></script>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script src="../js/axios-0.18.0.js"></script>
<script>
    let a=document.getElementById("aaa");
    var vue = new Vue({
        el: '#app',
        data: {
            password1: "",
            password2: "",
            password3: "",
        },
        created() {
            axios.post("/user/getUsername.do").then((res) => {
                if (res.data.flag) {
                    this.$message.success("查到了原密码");
                    document.getElementById("0").value=res.data.data;
                } else {
                    this.$message.error("没查到原密码")
                }
            })
        },
        methods: {
            update() {  
                let a = document.getElementById("1");
                let b = document.getElementById("2");
                if (a == b) {
                    this.$message.success("输入的密码一致")
                    axios.post("/user/usernameAndPassword").then((res) => {
                        if (res.data.flag) {
                            this.$message.success("修改成功")
                        } else {
                            this.$message.error("修改失败")
                        }
                    })
                }
                else {
                    this.$message.error("输入的密码不一致")
                }
        }
    }
    })
</script>
</html>